//
// $Id: Utility.java 8 2007-04-18 13:47:40Z z_hossain $
//
// xChess is a multiplatform graphical chess user interface
// Copyright (C) 2007  MD. Z. Hossain <z_hossain@users.sf.net>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  
// 02110-1301, USA.
//
// For more information visit http://xchess.sourceforge.net
//

package net.sourceforge.xchess;

public class Utility {
	
	public static final int[] INITIAL_BOARD = {
		 3,  1,  2,  4,  5,  2,  1,  3,
		 0,  0,  0,  0,  0,  0,  0,  0,
		-1, -1, -1, -1, -1, -1, -1, -1,
		-1, -1, -1, -1, -1, -1, -1, -1,
		-1, -1, -1, -1, -1, -1, -1, -1,
		-1, -1, -1, -1, -1, -1, -1, -1,
		 6,  6,  6,  6,  6,  6,  6,  6,
		 9,  7,  8, 10, 11,  8,  7,  9,
	};
	
	public static int compare(int value, int p, int z, int n) {
		if(value > 0) return p;
		else if(value < 0) return n;
		else return z;
	}
	
	public static <T extends Number> boolean equalOr(T value, T alt, T... alts) {
		boolean result = (value == alt);
		for(T a : alts) {
			result |= (value == a);
		}
		return result;
	}
	
	public static <T extends Number> boolean equalAnd(T value, T alt, T... alts) {
		boolean result = (value == alt);
		for(T a : alts) {
			result &= (value == a);
		}
		return result;
	}
	
//	public static <T> T doColor(int color, T white, T black) {
//		if(color == Pieces.COLOR_WHITE) return white;
//		else return black;
//	}
}
